package com.example.controller;

import com.example.service.BusinessService;
import io.seata.core.context.RootContext;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class OrderController {

    @Autowired
    private BusinessService businessService;

    @GetMapping("createOrder")
    public String createOrder(@RequestParam("accoundId") Integer accountId, @RequestParam("amount") Long amount,
                              @RequestParam(value = "hasException", defaultValue = "false") boolean hasException){
        System.out.println("xid:" + RootContext.getXID());
        businessService.createAccountOrder(accountId,amount,hasException);
        return "下单成功";

    }
}
